<?php

require_once("Calc_unit.php");

class Symptom_analyse_center
{
	private $data2method = array();
	
	public function __construct()
	{
		//如果一个方法涉及到某项指标，则把它像下面这样和指标建立联系，这样后面的notice_field_change才可以做统一处理；
		$this->data2method["totalCholesterol"] = array(
				new total_cholesterol_critical_exceed(),
				new total_cholesterol_exceed()
				);
		$this->data2method["height"] = array(
				//new xxxx1
				//new xxxx2
				);
		
		$this->data2method["weight"] = array(
				);
		
		$this->data2method["waistline"] = array(
				);
		
		$this->data2method["bloodPressureHigh"] = array(
				new critical_hypertension(),
				new first_stage_hypertension(),
				new second_stage_hypertension(),
				);
		
		$this->data2method["bloodPressureLow"] = array(
				new critical_hypertension(),
				new first_stage_hypertension(),
				new second_stage_hypertension(),
				);
		
		$this->data2method["highDensityLipoprotein"] = array(
				);
		
		$this->data2method["lowDensityLipoprotein"] = array(
				new low_density_lipoprotein_critical_exceed(),
				new low_density_lipoprotein_exceed(),
				);
		
		$this->data2method["triglyceride"] = array(
				new triglyceride_critical_exceed(),
				new triglyceride_exceed(),
				);
		
		$this->data2method["fastingBloodSugar"] = array(
				new critical_diabetes(),
				new diabetes()
				);
		
		$this->data2method["normalBloodSugar"] = array(
				new normal_blood_sugar_exceed(),
				);
		
		$this->data2method["smoking"] = array(
				);
		
		$this->data2method["drinkingWeekFreq"] = array(
				);
		
		$this->data2method["doseOfDrink"] = array(
				);
		
		$this->data2method["sportsWeekFreq"] = array(
				);
		
		$this->data2method["sportsDuration"] = array(
				);
		
		$this->data2method["pressure"] = array(
				);
	}
	
	public function get_type_to_name_map()
	{
		$type2name = array();
		foreach ($this->data2method as $field=>$calc_unit_ary)
		{
			for ($i = 0; $i < count($calc_unit_ary); $i++)
			{
				$calc_unit = $calc_unit_ary[$i];
				$type2name[$calc_unit.type] = $calc_unit.name;
			}
		}
		
		return $type2name;
	}
	
	
	//字段有更新，直接通知这里，这个模块中的逻辑会处理一切
	public function notice_field_change($uid, $field)
	{
		$result = array();
		$calc_unit_ary = $this->data2method[$field];
		for ($i = 0; $i < count($calc_unit_ary); $i++)
		{
			$calc_unit = $calc_unit_ary[$i];
			$b = $calc_unit->get_result($uid);
			if($b)
			{
				$result[$calc_unit.type] = $calc_unit.name;	
			}
		}
		
		return $result;
	}

}
?>